package com.kehutong.charge.util.enums;

import org.coraframework.util.HashID;

import java.util.EnumSet;
import java.util.HashMap;

/**
 * @program: kht
 * @description: 缴费账单状态枚举
 * @author: joneron
 * @create: 2021/7/5
 **/
public enum ChargeBillStatusEnum implements HashID {

    /**
     * 缴费状态
     */
    BILL_UN_PAID("1","未缴费"),
    BILL_PAID("2","已缴费"),
    BILL_REFUND("3","已退款"),
    BILL_PAID_PART("4","部分缴费"),
    BILL_REFUND_PART("5","部分退款"),
    //BILL_PAID_CANCEL("6","已作废"), //8.27 版本取消
    /**
     * 账单状态
     */
    BILL_PAID_FINISH("7","已完成"),
    BILL_PAID_CLOSE("8","已关闭"),
    BILL_WAIT_PAID("9","待缴费"), // 未缴费 ，部份缴费，部份退款
    ;

    private final String id;
    private final String desc;

    private ChargeBillStatusEnum(String id, String desc) {
        this.id = id;
        this.desc = desc;
    }



    public static ChargeBillStatusEnum getEnum(String desc){
        for (ChargeBillStatusEnum typeEnum : values()) {
            if (typeEnum.desc.equals(desc)) {
                return typeEnum;
            }
        }
        return null;
    }

    public static ChargeBillStatusEnum getEnum2(String id){
        for (ChargeBillStatusEnum typeEnum : values()) {
            if (typeEnum.id.equals(id)) {
                return typeEnum;
            }
        }
        return null;
    }


    public static String getEnumDesc(String id){
        for (ChargeBillStatusEnum typeEnum : values()) {
            if (typeEnum.id.equals(id)) {
                return typeEnum.desc;
            }
        }
        return "";
    }


    public static String getEnumId(String desc){
        for (ChargeBillStatusEnum typeEnum : values()) {
            if (typeEnum.desc.equals(desc)) {
                return typeEnum.id;
            }
        }
        return "";
    }


    /**
     * 获取map集合
     * @return
     */
    public static HashMap<String,String> getMap() {
        HashMap<String, String> map = new HashMap<>();
        for (ChargeBillStatusEnum enums : EnumSet.allOf(ChargeBillStatusEnum.class)) {
            map.put(enums.id, enums.desc);
        }
        return map;
    }

    @Override
    public String getId() {
        return id;
    }


    @Override
    public String getDesc() {
        return desc;
    }
}
